package array

func UniqWith(array []T, comparator func(arrVal, othVal T)) []T {
	var cacheSet = map[T]struct{}{}
	var ret []T
	for _, value := range array {
		if _, ok := cacheSet[value]; !ok {
			ret = append(ret, value)
			cacheSet[value] = struct{}{}
		}
	}
	return ret
}
